package com.example.dml.observer_pattern.event;

import java.lang.reflect.Method;

/**
 * @Authors：gaoyang
 * @CreateTime：2021/11/2 22:59
 * @Description：监听器的一种包装，标准事件源格式的定义
 */
public class Event {
    //事件源，事件是由谁发起的，保存起来
    private Object source;
    //事件触发，要通知谁
    private Object target;
    //事件触发，要做什么动作，回调
    private Method callBack;
    //事件的名称，触发的是什么事件
    private String trigger;
    //时间触发的时间
    private long time;

    public Event(Object target,Method callBack){
        this.target = target;
        this.callBack = callBack;
    }

    public Event setSource(Object source){
        this.source = source;
        return this;
    }
    public Event setTime(long time){
        this.time = time;
        return this;
    }
    public Object getSource(){
        return source;
    }
    public Event setTrigger(String trigger){
        this.trigger = trigger;
        return this;
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Method getCallBack() {
        return callBack;
    }

    public void setCallBack(Method callBack) {
        this.callBack = callBack;
    }

    public String getTrigger() {
        return trigger;
    }

    public long getTime() {
        return time;
    }
}
